
%\documentclass[letterpaper,12pt]{article}
%\usepackage[x11names,rgb]{xcolor}
%\usepackage{tikz}
%\usetikzlibrary{snakes}
%\usetikzlibrary{arrows}
%\usetikzlibrary{shapes}
%\usetikzlibrary{backgrounds}
%\usepackage{amsmath}
%\oddsidemargin 0in
%\evensidemargin 0in
%\topmargin 0in
%\headheight 0in
%\headsep 0in
%\textheight 9in
%\textwidth 6.5in
%\begin{document}
%\pagestyle{empty}
%\vspace*{\fill}
%\begin{center}

\begin{tikzpicture}

\draw[very thin,color=gray,xstep=1, ystep=0.5] (-0.1,-0.1) grid (4, 4.5);
%1cm spacing for x-axis and 0.5 cm spacing for y-axis
\draw[->] (-0.2,0) -- (4.2, 0) node[right] {$n_p$};
\draw[->] (0,-0.2) -- (0, 5) node[above] {seconds};

%Draw the x-axis ticks now
\foreach \pos/\label in {0.5/1, 1.5/2, 2.5/4, 3.5/8} {
\draw (\pos,0) -- (\pos,-0.1) (\pos cm, -2.5ex) node [anchor=base,fill=white,inner sep=1pt]  {\scriptsize \label};
}

\newdimen\ysc

\ysc=0.001 cm

%Draw the y-axis ticks now...
\foreach \label in {0, 500,...,4500} {
\draw (-2.5ex, \ysc*\label) node [anchor=base,fill=white,inner sep=1pt] {\scriptsize \label};
}

%Draw the legend now
\draw[fill=white, very thick] (1.5, 3.6) rectangle (3.9, 4.4);
\draw[fill=black!90, thick] (1.7, 4.2) rectangle +(0.3, 0.1);
\draw[fill=black!50, thick] (1.7, 3.95) rectangle +(0.3, 0.1);
\draw[fill=black!20, thick] (1.7, 3.7) rectangle +(0.3, 0.1);

\draw (2, 4.25) node[right] {\tiny{Ripple}};
\draw (2, 4) node[right] {\tiny{Ripple-Ripple}};
\draw (2, 3.75) node[right] {\tiny{Two Stage}};

\newdimen\mypos

%vala, valb and valc are respectively times for ripple, ripple-ripple and hybrid
\foreach \pos/\vala/\valb/\valc in { 
 0 / 4000 / 700 / 100 ,
 1 / 1450 / 400 / 75 ,
 2 / 550 / 300  / 50  ,
 3 / 150 / 120  / 40
 }
 { 

\mypos=\pos cm
%Filing the table below the plot...
\advance \mypos by 0.5 cm

%width of each column is 0.8/3 = 0.26667 cm (since, there are 3 columns and we want them at the middle of each x-segment (1 cm width)
%But, first we must position the first column at -0.4 cm from the mid-pt.
%(so we leave 0.1 cm on either side of the columns and the total width of the columns adds up to 0.8 cm) 

%First Ripple
\advance \mypos by -0.4 cm
\draw[fill=black!90] (\mypos,0) rectangle +(0.26667,\ysc*\vala);

%Next Ripple-Ripple
\advance \mypos by 0.26667 cm
\draw[fill=black!50] (\mypos,0) rectangle +(0.26667,\ysc*\valb);

%Last Hybrid
\advance \mypos by 0.26667 cm
\draw[fill=black!20] (\mypos,0) rectangle +(0.26667,\ysc*\valc);

}

\end{tikzpicture}

%\end{center}
%\vspace*{\fill}
%\end{document}
